#ifndef DOUBAN_MINIBLOG_RECOMMENDVIEWER_H
#define DOUBAN_MINIBLOG_RECOMMENDVIEWER_H

#include "RecommendSubViewer.h"
#include <QXmlStreamReader>
#include <QTextDocument>
#include <QTextBrowser>
#include <QPushButton>
#include <QMovie>
#include <QLabel>

class QKeyEvent;
class QNetworkReply;
namespace Douban
{
	class MiniBlogEntry;
	class DoubanContext;
	class RecommendSubViewer;
	class RecommendViewer : public QFrame
	{
		Q_OBJECT
		Q_PROPERTY(QString reviewStyleSheet READ reviewStyleSheet WRITE setReviewStyleSheet)
		public:
			void viewEntry(MiniBlogEntry*);



			RecommendViewer(DoubanContext* c);
			~RecommendViewer();

			QString reviewStyleSheet(){return QString::null;}
			void setReviewStyleSheet(QString ss) { reviewText.document()->setDefaultStyleSheet(ss); }
		protected:
			void closeEvent(QCloseEvent*);
		private:
			DoubanContext* m_context;
			QWidget			ratingWidget;
			QPushButton		rate1Btn;
			QPushButton		rate2Btn;
			QPushButton		rate3Btn;
			QPushButton		rate4Btn;
			QPushButton		rate5Btn;
			QPushButton		gotoWebBtn;
			QLabel			titleLabel;
			QLabel			iconLabel;
			QLabel			detailLabel;
			QTextBrowser		overViewText;
			QTextBrowser		reviewText;
			QPushButton		collectBtn;
			QLabel		m_loadingLabel;
			QMovie		m_loadingMovie;

			MiniBlogEntry*		m_currentEntry;
			RecommendSubViewer	m_subViewer;

			QXmlStreamReader m_xmlParser;

			QNetworkReply* r_getInfoReply;
			QNetworkReply* r_getReviewReply;
			QNetworkReply* r_getCollectionReply;

			void setRating(int);
			void parseInfo();
			void parseReview();
			void cleanup();
			void showLoading();
			void hideLoading();
		private slots:
			void openUrl(const QUrl&);
			void onReceiveInfoData();
			void onReceiveReviewData();
			void onReceiveCollectionData();

			void gotoWeb();
			void showSubViewer();
		private:
			Q_DISABLE_COPY(RecommendViewer)
			static const QString Review_Entry_Template;

	};
}
#endif // RECOMMENDVIEWER_H
